﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: FZH
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;
using FriendStar.Code;
using FriendStar.Domain.Entity.WareHouse;
using FriendStar.Domain.IRepository.WareHouse;
using FriendStar.Repository.WareHouse;

namespace FriendStar.Application.WareHouse
{
    /// <summary>
	/// 数据视图 V_CLK_61_PC_MaterialProAIAOAcco 对应的数据应用功能类。
	/// </summary>
	public class V_CLK_61_PC_MaterialProAIAOAccoApp
    {       
        private string UseUnit = Configs.GetValue("UseUnit");  

        private IV_CLK_61_PC_MaterialProAIAOAccoRepository service = new V_CLK_61_PC_MaterialProAIAOAccoRepository();

        public List<V_CLK_61_PC_MaterialProAIAOAccoEntity> GetList(string keyword)
        {
            var expression = ExtLinq.True<V_CLK_61_PC_MaterialProAIAOAccoEntity>();
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.FInOutID == keyword);
            }
            return service.FindList(expression);
        }
        
        public List<V_CLK_61_PC_MaterialProAIAOAccoEntity> GetList(Pagination pagination, string keyword)
        {
            var expression = ExtLinq.True<V_CLK_61_PC_MaterialProAIAOAccoEntity>();
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.FInOutID == keyword);
            }
            return service.FindList(expression, pagination);
        }

        public List<V_CLK_61_PC_MaterialProAIAOAccoEntity> GetList1(Pagination pagination, string MaterialNO, string MaterialCode)
        {
            var expression = ExtLinq.True<V_CLK_61_PC_MaterialProAIAOAccoEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            expression = expression.And(t => t.FDocuTypeNO != "LR");
            //if (!string.IsNullOrEmpty(MaterialNO))
            //{
            //    expression = expression.And(t => t.MaterialNO == MaterialNO);
            //}
            if (!string.IsNullOrEmpty(MaterialCode))
            {
                expression = expression.And(t => t.MaterialCode.Contains(MaterialCode));
            }
            return service.FindList(expression, pagination);
        }

        public List<V_CLK_61_PC_MaterialProAIAOAccoEntity> GetList2(Pagination pagination, string MaterialNO, string FVoucherNo, string MaterialCode)
        {
            var expression = ExtLinq.True<V_CLK_61_PC_MaterialProAIAOAccoEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            expression = expression.And(t => t.FDocuTypeNO == "LR");
            //if (!string.IsNullOrEmpty(MaterialNO))
            //{
            //    expression = expression.And(t => t.MaterialNO == MaterialNO);
            //}
            if (!string.IsNullOrEmpty(FVoucherNo))
            {
                expression = expression.And(t => t.FVoucherNo.Contains(FVoucherNo));
            }
            if (!string.IsNullOrEmpty(MaterialCode))
            {
                expression = expression.And(t => t.MaterialCode.Contains(MaterialCode));
            }
            return service.FindList(expression, pagination);
        }

        public V_CLK_61_PC_MaterialProAIAOAccoEntity GetForm(string keyValue)
        {
            return service.FindEntity(t => t.FInOutID == keyValue);
        }
    }
}